use super::{ChannelState, EndReason, OriginateChannel};

///通用的
#[derive(Debug, PartialEq, Eq)]
pub struct UniversalEvent {
	pub ch_id: u32,
	pub uuid: String,
}

#[derive(Debug, PartialEq, Eq)]
pub struct ChannelDtmfEvent {
	pub uuid: String,
	pub dtmf: String,
}

#[derive(Debug, PartialEq, Eq)]
pub struct CommandReplyEvent {
	pub uuid: String,
}

#[derive(Debug, PartialEq, Eq)]
pub struct ChannelStateEvent {
	pub uuid: String,
}

#[derive(Debug, PartialEq, Eq)]
pub struct ChannelCallStateEvent {
	pub uuid: String,
}

///正式接通消息
#[derive(Debug, PartialEq, Eq)]
pub struct ChannelBridgeEvent {
	pub uuid: String,
}

///后台执行事件
#[derive(Debug, PartialEq, Eq)]
pub struct ChannelBackgroundJobEvent {
	pub uuid: String,
	pub command: String,
	pub arg: String,
	pub is_ok: bool,
	pub body: String,
}

///向业务层发送的事件,业务层根据这些事件进行相应操作
/// 此事件发送的接收者是指定的某一个通道,所以发送的消息不需要指定通道号
#[derive(Debug)]
pub enum ChannelEvent {
	///外呼时通道呼叫状态变更
	ChannelCallState(u32, ChannelState),

	///通道进行应答
	///由于sip消息可能重复发送,可能重复收到此消息.
	ChannelAnswer(u32),
	///这个是按键的事件
	DTMF(u32, char),
	PlaybackStop(u32),
	///通道正在关联另一个通道
	ChannelBridge,
	///两个通道拆分开
	ChannelUnbridge,
	///通道挂断
	ChannelHangup(u32, EndReason),
	///一旦发起，通道发起事件就会被触发。
	ChannelOriginate(OriginateChannel),
	///呼叫准备失败..此事件是还未开始呼叫的准备阶段出现失败
	OriginateError(EndReason),
	///用户注册事件
	UserRegist,
	Unknow,
}
